package com.beidasoft.web.util.encrypt;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * @Author zhangwj1
 * @Description TODO
 * @date 2022/10/9 10:28
 * @Version 1.0
 */
@Configuration
@ConfigurationProperties(
        prefix = "bdp.system-config.enc-and-dec"
)
public class EncAndDecProperties {
    private String encryptType = "AES";
    private EncryptSecretKey encryptSecretKey = new EncryptSecretKey();
    private TransmissionEncryption transmissionEncryption = new TransmissionEncryption();

    public EncAndDecProperties() {
    }

    public String getEncryptType() {
        return this.encryptType;
    }

    public void setEncryptType(String encryptType) {
        this.encryptType = encryptType;
    }

    public EncryptSecretKey getEncryptSecretKey() {
        return this.encryptSecretKey;
    }

    public void setEncryptSecretKey(EncryptSecretKey encryptSecretKey) {
        this.encryptSecretKey = encryptSecretKey;
    }

    public TransmissionEncryption getTransmissionEncryption() {
        return this.transmissionEncryption;
    }

    public void setTransmissionEncryption(TransmissionEncryption transmissionEncryption) {
        this.transmissionEncryption = transmissionEncryption;
    }

    public static class TransmissionEncryption {
        private Boolean isEncryption = false;
        private String type = "AES";
        private String encryptedDataKey = "encryptedData";
        private String encryptedSecretKey = "encryptedSecret";

        public TransmissionEncryption() {
        }

        public Boolean getIsEncryption() {
            return this.isEncryption;
        }

        public void setIsEncryption(Boolean encryption) {
            this.isEncryption = encryption;
        }

        public String getType() {
            return this.type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public String getEncryptedDataKey() {
            return this.encryptedDataKey;
        }

        public void setEncryptedDataKey(String encryptedDataKey) {
            this.encryptedDataKey = encryptedDataKey;
        }

        public String getEncryptedSecretKey() {
            return this.encryptedSecretKey;
        }

        public void setEncryptedSecretKey(String encryptedSecretKey) {
            this.encryptedSecretKey = encryptedSecretKey;
        }
    }

    public static class EncryptSecretKey {
        private RSASecretKey rsa = new RSASecretKey();
        private SM2SecretKey sm2 = new SM2SecretKey();
        private SM4SecretKey sm4 = new SM4SecretKey();
        private HSMSecretKey hsm = new HSMSecretKey();

        public EncryptSecretKey() {
        }

        public RSASecretKey getRsa() {
            return this.rsa;
        }

        public void setRsa(RSASecretKey rsa) {
            this.rsa = rsa;
        }

        public SM2SecretKey getSm2() {
            return this.sm2;
        }

        public void setSm2(SM2SecretKey sm2) {
            this.sm2 = sm2;
        }

        public SM4SecretKey getSm4() {
            return this.sm4;
        }

        public void setSm4(SM4SecretKey sm4) {
            this.sm4 = sm4;
        }

        public HSMSecretKey getHsm() {
            return this.hsm;
        }

        public void setHsm(HSMSecretKey hsm) {
            this.hsm = hsm;
        }

        public static class HSMSecretKey {
            private String key = "";

            public HSMSecretKey() {
            }

            public String getKey() {
                return this.key;
            }

            public void setKey(String key) {
                this.key = key;
            }
        }

        public static class SM4SecretKey {
            private String key = "7ba63dfb9ac249b8bf6111388388586f";

            public SM4SecretKey() {
            }

            public String getKey() {
                return this.key;
            }

            public void setKey(String key) {
                this.key = key;
            }
        }

        public static class SM2SecretKey {
            private String publicKey = "3059301306072a8648ce3d020106082a811ccf5501822d03420004bbce9b87f9b0a36d39e94bef8433beb542f39fe9f8ced9ea3895961dc5aa638754f6b8ed004aed5106cf4c17e276fa89be45fb081ca34d218a176796006a8ce2";
            private String privateKey = "308193020100301306072a8648ce3d020106082a811ccf5501822d0479307702010104205cf65ee9273572c365acca5bb0560553e703cdb4874c59d9ef129e22375aaa7aa00a06082a811ccf5501822da14403420004bbce9b87f9b0a36d39e94bef8433beb542f39fe9f8ced9ea3895961dc5aa638754f6b8ed004aed5106cf4c17e276fa89be45fb081ca34d218a176796006a8ce2";

            public SM2SecretKey() {
            }

            public String getPublicKey() {
                return this.publicKey;
            }

            public void setPublicKey(String publicKey) {
                this.publicKey = publicKey;
            }

            public String getPrivateKey() {
                return this.privateKey;
            }

            public void setPrivateKey(String privateKey) {
                this.privateKey = privateKey;
            }
        }

        public static class RSASecretKey {
            private String publicKey;
            private String privateKey;

            public RSASecretKey() {
            }

            public String getPublicKey() {
                return this.publicKey;
            }

            public void setPublicKey(String publicKey) {
                this.publicKey = publicKey;
            }

            public String getPrivateKey() {
                return this.privateKey;
            }

            public void setPrivateKey(String privateKey) {
                this.privateKey = privateKey;
            }
        }
    }
}
